package com.wctj.api.base.utils;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @description:
 * @author: yyqiang
 * @Copyright: Copyright (c) 浙江日报
 * @date: 2022/12/27 17:31
 * @version: 1.0.0
 */
public class ThreadPoolUtils {

    public static ExecutorService getAsyncExecutorService() {
        return asyncExecutorService;
    }

    public static ExecutorService getAsynMultiChannelPublishExecutor() {
        return ASYNC_MULTI_CHANNEL_PUBLISH_EXECUTOR;
    }

    private static ExecutorService asyncExecutorService = new ThreadPoolExecutor(8, 32, 10000L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(512), new ThreadFactoryBuilder().setNameFormat("asyncExecutor").build());

    private static ExecutorService ASYNC_MULTI_CHANNEL_PUBLISH_EXECUTOR = new ThreadPoolExecutor(4, 32, 10000L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(512), new ThreadFactoryBuilder().setNameFormat("asyncMultiChannelPublishThread").build());

}
